#include <iostream>
#include <memory>
using namespace std;

struct MyDelete {
    void operator()(int *p) {
        cout << "delete" << endl;
        delete p;
    }
};

int main() {
    auto upw1(make_unique<int[]>(2));   // with make func make_unique需要设置C++14
    unique_ptr<int> upw2(new int);  // without make func

    upw1[21] = 1;
    unique_ptr<int, MyDelete> ptr2(new int(1));
    // auto ptr(make_unique<int, MyDelete>(1)); //报错
    cout << "main finish! " << upw1[1] << endl;
    return 0;
}

/*
main finish! 0
delete
*/